<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="renderer" content="webkit" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
    <title>{{title}}</title>
    <link rel="stylesheet" href="/visit/" type="text/css" media="all" />
    <!--<script type="text/javascript" src="/visit/" defer></script>-->
    <style type="text/css" media="all">
        html,
        body {
            overflow: auto !important;
            overflow-x: auto !important;
            overflow-y: auto !important;
        }
        body {
            font-family: "Segoe UI","Lucida Grande",Helvetica,Arial,"微软雅黑","Microsoft YaHei",FreeSans,Arimo,"Droid Sans","wenquanyi micro hei","Hiragino Sans GB","Hiragino Sans GB W3",FontAwesome,sans-serif !important;
        }
        .tree-view-list {
            position: fixed;
            max-width: 300px;
            right: 3px;
            top: 5px;
            border: 1px solid #fa1;
            background-color: #fdfbf6;
        }
        .tree-view-list > ol {
            padding: 0 3px 0 22px;
            margin: 5px 2px 5px 0;
        }
        .markdown-preview {
            margin: auto 0.7em !important;
        }
        .markdown-preview h1:nth-child(1) {
            text-indent: 2em;
        }
        #icp_info {
        	text-align: center;
        }
    </style>
</head>
<body>
    <div class="markdown-preview">
        {{content}}
    </div>
    <p id="icp_info"><a href="http://www.miitbeian.gov.cn/">鄂ICP备15003593号-1 </a></p>
    <script src="/static/loader.js" type="text/javascript" charset="utf-8"></script>
    <script type="text/javascript" charset="utf-8">
        var srcs = {
            'jq': '/static/jquery-1.12.4.min.js',
            'draggabilly': '/static/draggabilly/draggabilly.pkgd.min.js',
            'tl': '/tree-list.txt?t=' + (new Date()).getTime()
        };
        
        function appendTreeView($, tv_src) {
            $.ajax({
                url: tv_src,
                type: 'GET',
                dataType: 'text',
                success: function(data) {
                    $('body').append([
                        '<div class="tree-view-list">',
                            data,
                        '</div>'
                    ].join(''));
                    var $ca = $('.tree-view-list').find('a[href="' + location.pathname + '"]');
                    $ca.css({
                        'color': '#fa5',
                        'text-decoration-line': 'none;'
                    }).attr('href', 'javascript:;');
                    var $pl = $ca.closest('li').css('color', '#fa5').parent('ol').prev('li');
                    while($pl.length > 0) {
                        $pl.css('color', '#fa5').find('span:eq(0)').css('color', '#fa5');
                        $pl = $pl.parent('ol').prev('li');
                    }
                    
                    loadJS(srcs['draggabilly'], function() {
                        var $elem = $('.tree-view-list');
                        var pos = $elem.position();
                        $elem.draggabilly();
                        $elem.css('position', 'fixed');
                        $elem.css({
                            'left': pos.left + 'px',
                            'top': pos.top + 'px'
                        });
                        // $elem.css('position', 'relative');
                    });
                }
            });
        }
        
        window.onload = function() {
            loadJS(srcs['jq'], function() {
                appendTreeView($, srcs['tl']);
                
                $('img[data-src]').each(function(_i, img) {
                    var $img = $(img);
                    $img.attr('src', $img.attr('data-src'));
                });
            });
            loadCSS('/static/style.css');
        };
    </script>
</body>
</html>
